import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';

import 'package:flutter_app_demo/ui_demo/mult_page_demo.dart';
import 'package:flutter_app_demo/http_demo/http_demo.dart';
import 'package:flutter_app_demo/ui_demo/ui3dcard/3d_card_demo.dart';
import 'package:flutter_app_demo/ui_demo/tab_grid_and_stepper_form_gloabl_key_sp_demo.dart';
import 'package:flutter_app_demo/async_demo/async_code_demo.dart';
import 'package:flutter_app_demo/ui_demo/animation_demo.dart';
import 'package:flutter_app_demo/ui_demo/touch_demo.dart';
import 'package:flutter_app_demo/io_demo/io_file_demo.dart';
import 'package:flutter_app_demo/redux_demo/redux_demo.dart';

import 'package:flutter_app_demo/ui_demo/ui_weather_forecast/ui_weather_demo.dart';

final ThemeData themeData = ThemeData(
    canvasColor: Colors.white,
    accentColor: Colors.redAccent,
);

void main() {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
    
    runApp(MaterialApp(
        //home: MyApp(), // When using initialRoute, be sure you do not define a home property.
        
        debugShowCheckedModeBanner: false,
        initialRoute: "/",
        routes: {
            "/": (context) => MyDemoApp(),
            "/thirdPage": (context) => PageThree().builder(context), // <-----此处注册的PageThree，在.../ui_demo/mult_page_demo.dart里会用到
        },
        theme: themeData,
    ));
}

class MyDemoApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
        return Scaffold(
            appBar: AppBar(
                title: Text("Demo"),
            ),
            body: Container(
                margin: EdgeInsets.all(10.0),
                child: ListView(
                    children: <Widget>[
                        RaisedButton(
                            onPressed: () {
                                Navigator.push(context, UIDemo());
                            },
                            child: Text("GridView,TabView,Stepper,Form和GlobalKey,SharedPreferences的demo"),
                        ),
                        RaisedButton(
                            onPressed: () {
                                Navigator.push(context, AnimationDemo());
                            },
                            child: Text("动画demo"),
                        ),
                        RaisedButton(
                            onPressed: () {
                                Navigator.push(context, TouchDemo());
                            },
                            child: Text("触摸事件demo"),
                        ),
                        RaisedButton(
                            onPressed: () {
                                Navigator.push(context, MaterialPageRoute<Null>(builder: (BuildContext ctx) {//<----这里push方式只是做个类比本质和其他的一样
                                    return Page1();
                                }));
                            },
                            child: Row(
                                mainAxisSize: MainAxisSize.max,
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: <Widget>[Icon(Icons.panorama), Text("多个页面跳转 Multipl Page Jump Demo")],
                            )),
                        RaisedButton(
                            onPressed: () {
                                Navigator.push(context, AsyncCodeDemo());
                            },
                            child: Text("异步编程"),
                        ),
                        RaisedButton(
                            onPressed: () {
                                Navigator.push(context, IOFileDemo());
                            },
                            child: Text("文件读写"),
                        ),
                        RaisedButton(
                            child: Text("两种请求网络的方式 Http demo"),
                            onPressed: () {
                                Navigator.push(context, HttpDemo());
                            },
                        ),
                        RaisedButton(
                            child: Text("ReDux库介绍"),
                            onPressed: () {
                                Navigator.push(context, ReDuxDemo());
                            },
                        ),
                        RaisedButton(
                            child: Text("UI:3dcard"),
                            onPressed: () {
                                Navigator.push(context, UI3dCardPage());
                            },
                        ),
                        RaisedButton(
                            child: Text("UI:weather forecast"),
                            onPressed: () {
                                Navigator.push(context, WeatherPage());
                            },
                        ),
                    ],
                )));
    }
}
